<!-- #include virtual="/components_cb/client/initDialogEnv_tagged.inc"-->
<!-- #include virtual='components_cb/server/controls.inc' -->
<!-- #include virtual='components_cb/server/centers.inc' -->
<html>
<head>
    <title>OneSite</title>
    <script type="text/javascript" src="/components_cb/client/scriptinc_js.htm"></script>
    <script type="text/javascript" src="/components_cb/client/scriptinc_nocache_js.htm"></script>
    <script type="text/javascript" src="/components_cb/client/htmlstart.min.js"></script>
    <script type="text/javascript" src="/components_cb/client/datalist.min.js"></script>
    <script type="text/javascript" src="/components_cb/client/popup.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/components_cb/styles/base.min.css">
    <link rel="stylesheet" type="text/css" href="/components_cb/styles/form.min.css">
    <link href="/components_cb/styles/supertable.min.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript">
        //var top = window.dialogArguments;
        window.returnValue = false;
    </script>
    <script type="text/javascript">
        var otblDocTypes;
        var xmlMoreActionsTemp = NewXmlDOM(false);
        var xmlDocTypes = NewXmlDOM(false);
        var xmlDocTypesFilter = NewXmlDOM(false);
        var xmlCabinets = NewXmlDOM(false);
        var xmlMoreActions = NewXmlDOM(false);
        var xmlMoreActionsTest = "<root>" +
		            "<Row name='Edit' action='doEdit()' />" +
		            "<Row name='Delete' action='doDelete()' />" +
		            "<Row name='Push to property' action='doPushToProperty()' />" +
		            "<Row name='View properties' action='doViewProperty()' />" +
	                "</root>";     
    
    </script>
    <script type="text/javascript">
        var sXML;
        // var oPopup = window.createPopup();
        var atPMC = false;
        var _clickedRow;
        var bDocumentManagement = '<%=bDocumentManagement%>';
        var bSmartApp = '<%=bSmartApp%>';
        var bLeasingDeskeForms = "<%=bLeasingDeskeForms%>";
        if (top.gPropertyID.toString() === top.gCompanyID.toString())
        {
            atPMC = true;
        }
        function InitialLoad_Start()
        {
            xmlMoreActions.loadXML(xmlMoreActionsTest);
            StoreDataXml("xmlMoreActions", xmlMoreActions);
            otblDocTypes = $("#tblDocTypes").data("ST");
            sXML = "<Page><Request /></Page>";
            InitialLoad_GetData("", top.ShellAddress + "DocumentManagement/ASPX/DocumentType.aspx/GetCabinetDocumentTypes", sXML);
        }

        function setVisibilityAttributes()
        {
            var nodes;
            nodes = $(xmlDocTypes).find("Row");
            for (var i = 0; i < nodes.length; i++)
            {
                if (bDocumentManagement.toString() === '1')
                {
                    nodes.eq(i).attr("showMore", "true");
                }
                else
                {
                    nodes.eq(i).attr("showMore", "false");
                    $("#spnDocumentType").html("View document types");
                }
            }

            xmlDocTypesFilter.loadXML(xmlDocTypes.xml);
            StoreDataXml("xmlDocTypesFilter", xmlDocTypesFilter);
        }

        function InitialLoad_onDataReady()
        {
            InitialLoad_FillXML("CabinetDocumentTypes", 'xmlDocTypes', 'xmlDocTypesFilter');
            InitialLoad_FillXML("Cabinets", 'xmlCabinets', "");
            setVisibilityAttributes();
        }

        function Initialize()
        {
            if (bDocumentManagement.toString() === '1')
            {
                $("#btnNew").show();
                $("#tblCustomLabel").show();
            }
            else
            {
                $("#btnNew").hide();
                $("#tblCustomLabel").hide();
            }
            top.setLoadIndicator(false);
            rpiModalHeader.setLoadIndicator(false);
            otblDocTypes.updateTable();
            /*$.browser.chrome = $.browser.webkit && !!window.chrome;
            $.browser.safari = $.browser.webkit && !window.chrome;
            Fixes for some design related issues
            if ($.browser.mozilla) {
            $("#btnNew").css("height", "19px");
            $("#tblDocTypes_ST_wrapper").find("div:first.stContainer").css("min-height", "100px");
            $("#tblDocTypes_ST_wrapper").find("div:first.stContainer").css("height", "auto");
            }

            else if ($.browser.safari || $.browser.chrome) {
            $("#tblDocTypes_ST_wrapper").find("div:first.stContainer").css("min-height", "100px");
            $("#tblDocTypes_ST_wrapper").find("div:first.stContainer").css("height", "auto");
            $("#Table4 tbody tr").children().eq(1).css({ "padding-bottom": "2px", "vertical-align": "bottom", "padding-left": "8px" });
            $("#Table4 tbody tr").children().eq(4).css({ "vertical-align": "bottom", "padding-left": "8px" });
            $("#Table4 tbody tr").children().eq(4).find("div.RPI_WATCH").css("padding-bottom", "0");
            }
            else {
            $("#tblDocTypes_ST_wrapper").find("div:first.stContainer").css("height", "100px");
            }*/
        }

        function InitialLoad_onComplete()
        {
            Controls_Initialize();
            Initialize();
            Controls_WATCH_Initialize();
            //StoreDataXml('xmlDocTypes', xmlDocTypes);
            top.resizeDialog(bUsingIframe);
            top.setCustomDialogSize(690, 330);
            top.setActionButtonsPosition(0, 0, window);
        }

        /*$(document).ready(function() {
        $("#tblDocTypes").mouseover(function(event) {
        if ($(event.target)[0].nodeName.toUpperCase().toString() === "TH" && $(event.target)[0].title.toString() === "Click to sort") {
        $(event.target).css({ 'background': '#686fa1' });
        $(event.target).css({ 'color': '#FFFFFF' });
        $(event.target).mouseleave(function() {
        $(event.target).css({ 'background': '#3366cc' });
        });
        }
        });

        });*/
        var bRet;
        function doRefresh()
        {
            InitialLoad_Start();
        }

        function doClose()
        {
            //window.close();
            top.hideDialog(window.returnValue, window, bUsingIframe);
        }

        function doNew()
        {
            var bRet;
            top.SetPSCurrent("CABINETDOCTYPEID", "-1");
            top.SetPSCurrent("DOCTYPEEDITMODE", "EDIT");
            bRet = top.NavModalOpen('/documentmanagement/documenttypes/modalAddEditDocumentTypes.htm', 350, 200, false, window);
            top.RemovePageState("CABINETDOCTYPEID");
            top.RemovePageState("DOCTYPEEDITMODE");
            if (bRet)
            {
                $("#selCabinet").prop("selectedIndex", 0);
                doRefresh();
            }
        }

        function closePopup()
        {
            try
            {
                $('#popupdiv').hide();
            } catch (e) { }
        }

        function doViewProperty_callback() {
            top.RemovePageState('DOCUMENTTYPEID');
            return;
        }
        function doViewProperty()
        {
            //var bRet;
            closePopup();
            top.SetPSCurrent("DOCUMENTTYPEID", $(_clickedRow).attr("ID"));
            var oIframeData = { "onHide": doViewProperty_callback };
            bRet = top.NavModalOpen('/documentmanagement/DocumentTypes/modalViewProperties.htm', 380, 340, false, window, null, null, null, null, oIframeData);
            return;
        }
        function doPushToProperty_callback() {
            top.RemovePageState('DOCUMENTTYPEID');
            if (bRet) {
                $("#selCabinet").prop("selectedIndex", 0);
                doRefresh();
            }
            return;
        }
        function doPushToProperty()
        {
            //var bRet;
            closePopup();
            top.SetPSCurrent("DOCUMENTTYPEID", $(_clickedRow).attr("ID"));
            var oIframeData = { "onHide": doPushToProperty_callback };
            bRet = top.NavModalOpen('/documentmanagement/DocumentTypes/modalpushtoproperty.htm', 480, 380, false, window, null, null, null, null, oIframeData);
            return;
            /*
            top.RemovePageState('DOCUMENTTYPEID');
            if (bRet)
            {
            $("#selCabinet").prop("selectedIndex", 0);
            doRefresh();
            }
            */
        }
        function doEdit_callback() {
            top.RemovePageState("CABINETDOCTYPEID");
            top.RemovePageState("DOCTYPEEDITMODE");
            if (bRet) {
                $("#selCabinet").prop("selectedIndex", 0);
                doRefresh();
            }
            return;
        }
        function doEdit()
        {
            var oRow;
            closePopup();
            oRow = _clickedRow;
            top.SetPSCurrent("CABINETDOCTYPEID", $(oRow).attr("ID"));
            top.SetPSCurrent("DOCTYPEEDITMODE", "EDIT");
            var oIframeData = { "onHide": doEdit_callback };
            bRet = top.NavModalOpen('/documentmanagement/documenttypes/modalAddEditDocumentTypes.htm', 350, 200, false, window, null, null, null, null, oIframeData);
            return;
        }

        function doView()
        {
            var oRow;
            oRow = otblDocTypes.getClickedRow();
            top.SetPSCurrent("CABINETDOCTYPEID", $(oRow).attr("ID"));
            top.SetPSCurrent("DOCTYPEEDITMODE", "");
            bRet = top.NavModalOpen('/documentmanagement/documenttypes/modalAddEditDocumentTypes.htm', 350, 200, false, window);
            top.RemovePageState("CABINETDOCTYPEID");
            top.RemovePageState("DOCTYPEEDITMODE");
        }

        function doDelete()
        {
            closePopup();
            var sBodyText = "", bRet, oRow, ID;
            top.SetPSCurrent("BodyText", sBodyText);
            top.SetPSCurrent("ImageLabel", "Selected document type. It will be removed from all packet template(s).");
            bRet = top.NavSuperModal('delete', this.window);
            oRow = _clickedRow;
            ID = $(oRow).attr("ID");
            top.RemovePageState("ImageLabel");
            top.RemovePageState("BodyText");
            top.RemovePageState("Buttons");
            top.RemovePageState("Functions");
            top.RemovePageState("Buttons2");
            top.RemovePageState("Functions2");
            top.RemovePageState("Caption");

            if (bRet.toString() === "button1")
            {
                var strXML, oXML;
                strXML = "<Page><Request DocTypeID= '" + ID + "' /></Page>";
                oXML = top.objHTMUtils.NewPost("", top.ShellAddress + "DocumentManagement/ASPX/DocumentType.aspx/DeleteCustomDocumentType", strXML);

                if (validateXMLResults(oXML))
                {
                    var oConfirmRow, bSuccess;
                    oConfirmRow = $(oXML).find("ConfirmObject>Row");
                    if (oConfirmRow.length == 0)
                    {
                        alert("DEVELOPER ERROR::No Confirm object sent back!");
                        return false;
                    }
                    bSuccess = oConfirmRow.eq(0).attr("Success");
                    if (bSuccess.toString() === "1")
                    {
                        closePopup();
                        $("#selCabinet").prop("selectedIndex", 0);
                        doRefresh();
                        return true;
                    }
                    else
                    {
                        closePopup();
                        top.SetPSCurrent('BodyText', oConfirmRow.eq(0).attr("technicalReasonFailed"));
                        top.SetPSCurrent('Caption', 'Unable to delete document type');
                        top.SetPSCurrent('ImageLabel', 'Unable to delete document type');
                        top.NavSuperModal('attention', window);
                        top.RemovePageState('BodyText');
                        top.RemovePageState('Caption');
                        top.RemovePageState('ImageLabel');
                        return false;
                    }
                }
            }
            closePopup();
        }

        function doFilter()
        {
            var strSelected;
            strSelected = $("#selCabinet").val();
            xmlDocTypesFilter.loadXML(xmlDocTypes.xml);
            StoreDataXml("xmlDocTypesFilter", xmlDocTypesFilter);
            if (strSelected.toString() !== "All")
            {
                var oNodes;
                oNodes = $(xmlDocTypesFilter).find("Row[CabinetID!='" + strSelected + "']");
                for (var i = 0; i <= oNodes.length - 1; i++)
                {
                    oNodes.eq(i).remove();
                }
            }
            StoreDataXml("xmlDocTypesFilter", xmlDocTypesFilter);
            otblDocTypes.updateTable();
        }

        function showActionsMain(oThis) {
            $("#popupdiv").hide();
            var docTypeName, oNode, row, nHeight;
            _clickedRow = otblDocTypes.getClickedRow();
            xmlMoreActionsTemp.loadXML(xmlMoreActions.xml);
            StoreDataXml("xmlMoreActionsTemp", xmlMoreActionsTemp);
            docTypeName = $(_clickedRow).attr("Type");
            oNode = $(xmlMoreActionsTemp).find("*").eq(0);
            if (!atPMC)
            {
                row = $(xmlMoreActionsTemp).find("Row[name='Push to property']");
                if (row.length > 0)
                {
                    row.eq(0).remove();
                }
                row = $(xmlMoreActionsTemp).find("Row[name='View properties']");
                if (row.length > 0)
                {
                    row.eq(0).remove();
                }

                if ($(_clickedRow).attr("PMCDocumentTypeID").toString() !== top.emptyGUID.toString())
                {
                    row = $(xmlMoreActionsTemp).find("Row[name='Edit']");
                    if (row.length > 0)
                    {
                        row.eq(0).remove();
                    }
                }

                if ($(_clickedRow).attr("PMCDocumentTypeID").toUpperCase().toString() === 'F2B57D54-5BC0-436E-A617-614960ADAC24' || $(_clickedRow).attr("PMCDocumentTypeID").toUpperCase().toString() === '0D0B1ABD-8B1E-408A-91B7-7623898632C2')
                {
                    row = $(xmlMoreActionsTemp).find("Row[name='Delete']");
                    if (row.length > 0)
                    {
                        row.eq(0).remove();
                    }
                }
            }

            if ($(_clickedRow).attr("PMCDocumentTypeID").toUpperCase().toString() === 'F2B57D54-5BC0-436E-A617-614960ADAC24')
            {

                row = $(xmlMoreActionsTemp).find("Row[name='View properties']");
                if (row.length > 0)
                {
                    row.eq(0).remove();
                }

                row = $(xmlMoreActionsTemp).find("Row[name='Push to property']");
                if (row.length > 0)
                {
                    row.eq(0).remove();
                }

                row = $(xmlMoreActionsTemp).find("Row[name='Delete']");
                if (row.length > 0)
                {
                    row.eq(0).remove();
                }
            }

            if ($(_clickedRow).attr("IsCustom").toString() !== '1')
            {
                row = $(xmlMoreActionsTemp).find("Row[name='Delete']");
                if (row.length > 0)
                {
                    row.eq(0).remove();
                }
            }

            if (bDocumentManagement.toString() === "0")
            {

                row = $(xmlMoreActionsTemp).find("Row[name='Push to property']");
                if (row.length > 0)
                {
                    row.eq(0).remove();
                }

                row = $(xmlMoreActionsTemp).find("Row[name='View properties']");
                if (row.length > 0)
                {
                    row.eq(0).remove();
                }

                row = $(xmlMoreActionsTemp).find("Row[name='Edit']");
                if (row.length > 0)
                {
                    row.eq(0).remove();
                }

                row = $(xmlMoreActionsTemp).find("Row[name='Delete']");
                if (row.length > 0)
                {
                    row.eq(0).remove();
                }
            }
            if ($.browser.msie)
            {

                nHeight = ($(oNode).length <= 1 ? 50 : (($(oNode).length * 15) + 45));
            }
            else
            {
                if ($(xmlMoreActionsTemp).find("Row").length <= 1)
                {
                    nHeight = 40;
                }
                else if ($(xmlMoreActionsTemp).find("Row").length === 2)
                {
                    nHeight = 50;
                }
                else if ($(xmlMoreActionsTemp).find("Row").length === 3)
                {
                    nHeight = 70;
                }
                else
                {
                    nHeight = 85;
                }
            }
            StoreDataXml("xmlMoreActionsTemp", xmlMoreActionsTemp);
            top.rpPopup.PopupWindow = $("#popupdiv");
            top.rpshowActionList(top.rpPopup, xmlMoreActionsTemp, oThis, "", 200, nHeight, docTypeName);
        }        
    </script>
</head>
<%call CreateImports("errorhandling")%>
<%call CreateImports("supertable")%>
<%call CreateImports("modalheader")%>
<body class="datamodal" tabindex="-1" style='margin-right: 8px;'>
    <div class="RPI_MODALHEADER" id="mhead" pagetrail="Document Management setup - "
        pagelabel="Migrate document types" pageid="101.090.020.005" printaction="">
    </div>
    <table style="width: 100%;" cellpadding='0' cellspacing='0' border='0' id="Table3">
        <tr>
            <td style="vertical-align: top; font: bold;">
                <nobr><span id=spnDocumentType style="vertical-align:top;font:bold;">Create and manage document types.</span></nobr>
            </td>
            <td style='width: 100%'>
                &nbsp;
            </td>
        </tr>
    </table>
    <br />
    <table style="width: 100%;" cellpadding='0' cellspacing='0' border='0' id="Table4">
        <tr>
            <td style="vertical-align: bottom; font: bold 12pt arial;">
                <nobr>Document types</nobr>
            </td>
            <td style="padding-left: 8px;">
                <%Call Controls_CreateButtonCustom("btnNew","New","doNew()","1","30","10","display:none","","1","") %>
            </td>
            <td style='width: 100%'>
                &nbsp;
            </td>
            <td style="vertical-align: bottom;">
                <nobr>Cabinet</nobr>
            </td>
            <td style="padding-left: 8px;">
                <%Call Controls_CreateSelectDynamic("selCabinet","","","1","0","","All","","xmlCabinets","Cabinet","Name","ID","onChange=""doFilter()""") %>
            </td>
            <td style='width: 100%'>
                &nbsp;
            </td>
        </tr>
    </table>
    <div class="RPI_SUPERTABLE" id="tblDocTypes" rpinitialsort="Cabinet" rpdatasource="#xmlDocTypesFilter"
        rpdatanode="CabinetDocumentTypes" rpheader="true" rppagesize="8" rpmaxpagelinks="8"
        rpwidth="625px" rpheight="100px" rpscroll="FALSE" rpheightlock="true">
        <table style="display: none;">
            <thead>
                <tr>
                    <th style="text-align: center; width: 70px;" class="center" rpsortable="false">
                        Actions
                    </th>
                    <th style="text-align: center; width: 30px;" class="center" rpsortable="true" rpsortby="IsCustom"
                        title="Click to sort">
                        *
                    </th>
                    <th style="text-align: center; width: 140px;" class="center" rpsortable="true" rpsortby="StoreInCAS"
                        title="Click to sort">
                        Controlled Access
                    </th>
                    <th style="text-align: center;" class="center" rpsortable="true" rpsortby="Enabled"
                        title="Click to sort">
                        Enabled
                    </th>
                    <th style="text-align: center; width: 99px;" class="center" rpsortable="true" rpsortby="Type"
                        title="Click to sort">
                        Document type
                    </th>
                    <th style="text-align: center;" class="center" rpsortable="true" rpsortby="Cabinet"
                        title="Click to sort">
                        Cabinet
                    </th>
                    <th style="text-align: center;" class="center" rpsortable="true" rpsortby="EntityDescription"
                        title="Click to sort">
                        Attached to
                    </th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td style="text-align: left; vertical-align: middle; width: 70px;">
                        <!--<a rpclickaction="top.checkLink(event);doEdit();" href="#">Edit</a>&nbsp;-->
                        <a href='#' rpclickaction='top.checkLink(event);doView();'>View </a><span>&nbsp;</span>
                        <!--# if(@showMore === 'true') { -->
                        <a href='#' rpclickaction='top.checkLink(event);showActionsMain(this);'>More &nbsp;&rsaquo;</a>
                        <!--# } -->
                    </td>
                    <td style="text-align: center; vertical-align: middle; width: 30px;" class="center"
                        rpdatafld="IsCustom">
                        <!--# if(@IsCustom === '1') { -->
                        C
                        <!--# } else {-->
                        <div>
                            &nbsp;</div>
                        <!--# } -->
                    </td>
                    <td style="text-align: center; vertical-align: middle; width: 140px;" class="center"
                        rpdatafld="StoreInCAS">
                        <!--# if(@StoreInCAS === '1') { -->
                        <span style="font: 10pt; color: green; font-weight: 600;">&radic; </span>
                        <!--# } else {-->
                        <div>
                            &nbsp;</div>
                        <!--# } -->
                    </td>
                    <td style="text-align: center; vertical-align: middle;" class="center" rpdatafld="Enabled">
                        <!--# if(@Enabled === '1') { -->
                        <span style="font: 10pt; color: green; font-weight: 600;">&radic; </span>
                        <!--# } else {-->
                        <div>
                            &nbsp;</div>
                        <!--# } -->
                    </td>
                    <td style="text-align: left; vertical-align: middle; padding-left: 2px;" rpdatafld="Type" rpnowrap="true">
                    </td>
                    <td style="text-align: left; vertical-align: middle;" rpdatafld="Cabinet" rpnowrap="true">
                    </td>
                    <td style="text-align: left; vertical-align: middle;" rpdatafld="EntityDescription"
                        rpnowrap="true">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    <div id="popupdiv" style="display: none; z-index: 9999999;">
    </div>
    <table style="width: 100%;" cellpadding='0' cellspacing='0' border='0' id="tblCustomLabel"
        style="display: none">
        <tr>
            <td style='width: 100%'>
                &nbsp;
            </td>
            <td style="vertical-align: bottom; font: italic 8pt arial;">
                <nobr>* 'C' indicates a custom created document type. This type may be edited or deleted.</nobr>
            </td>
        </tr>
    </table>
    <br>
    <div class="IFrameButtons">
    <table id="buttons" border="0">

        <tr>
            <td>
                <%call Controls_CreateButton("btnClose","Close","doClose()","1","","")%>
            </td>
        </tr>
    </table>
    </div>
    <!--<TD style="text-align:center;vertical-align:middle;width:45px;">&nbsp;<xsl:if test=".[@Enabled = 1]"><span style='font:10pt marlett;color:green;'>a</span></xsl:if>&nbsp;</TD>-->
</body>
<script type="text/javascript">
    $(window).load(function ()
    {
        InitialLoad_ScreenReady();
        InitialLoad_Start();
        $(document).bind("mouseout", function () {
        }).bind("mouseup", function () {
            $('div#popupdiv').hide();
        });
    });
    var oCBConverted = { 'ie': true, 'firefox': true, 'chrome': true, 'safari': true };
</script>
</html>
